package model

import business.Destroyable
import org.itheima.kotlin.game.core.Painter

/**
 * created by lucus on 2019/4/26
 * e-mail: mcphilex1989@gmail.com
 * phone: 15652608401
 * 爆炸物 💥效果
 */
class Blast(override val x: Int, override val y: Int) : IView, Destroyable {

    override val width: Int = BaseConfig.GAME_UNIT

    override val height: Int = BaseConfig.GAME_UNIT

    private val imagePaths = arrayListOf<String>()
    private var index = 0

    init {
        (1..32).forEach {
            imagePaths.add("img/blast_$it.png")
        }
    }

    override fun draw() {
        var i = index % imagePaths.size
        Painter.drawImage(imagePaths[i], x, y)
        index++
    }

    override fun isDestroy(): Boolean {
        return index >= imagePaths.size
    }


}